home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SuperHack
/
SuperHack CD.bin
/
Hack
/
UNIX
/
MULTLOGN.ZIP
/
MULTLOGN.C
Wrap
C/C++ Source or Header
|
1996-06-23
|
4KB
|
182 lines
/* Program : To validate accounts & passwords on both
shadowed & unshadowed unix systems.
Author : The Shining/UPi (UK Division)
Date : Released 12/4/94
UNIX type : All unshadowed systems, and SUNOS shadowed systems */
#include <stdio.h>
#include <string.h>
#include <pwd.h>
FILE *fp;
int pw_system( void ), shadowed( void ), unshadowed( void );
void write_info( void ), display_notice( void );
struct passwd *pwentry, *getpwnam();
struct user {
char logname[10];
char key[9];
char salt[3];
} u;
char *getpass(), *pwdauth(), *crypt(), ans[2];
int invalid_user, stat;
int main( void )
{
strcpy(ans, "y");
while (strcmp(ans, "y") == NULL)
{
invalid_user = stat = 0;
display_notice();
printf("Enter login id:");
scanf("%9s", u.logname);
strcpy(u.key, getpass("Password:"));
setpwent();
if ((pwentry = getpwnam(u.logname)) == (struct passwd *) NULL)
invalid_user = 1;
else
strncpy(u.salt, pwentry->pw_passwd, 2);
if (invalid_user != 1) {
if ((stat = pw_system()) == 1) {
if ((stat = unshadowed()) == NULL) {
printf("Unshadowed valid account! - storing details\n");
write_info();
}
}
else
if ((stat = shadowed()) == NULL) {
printf("SUNOS Shadowed valid account! - storing details\n");
write_info();
}
else
invalid_user = 2;
}
if (invalid_user == 1)
printf("User unknown/not found in password file\n");
if (invalid_user == 2 )
printf("Password invalid\n");
printf("\n\nValidate another account?(y/n): ");
scanf("%1s", ans);
endpwent();
}
}
/* Check to see if shadow password system is used, in SUNOS the field
in /etc/passwd starts with a '#', if not, check to see if entry
is 13 chars, if not shadow must be in use. */
int pw_system( void )
{
if (strlen(pwentry->pw_passwd) != 13)
return(0);
else
if (strcmp(u.salt, "##") == NULL)
return(0);
else
return(1);
}
/* If system is unshadowed, get the 2 character salt from the password
file, and use this to encrypt the password entered. This is then
compared against the password file entry. */
int unshadowed( void )
{
if (pwentry->pw_passwd == crypt(u.key, u.salt))
return(0);
else
return(1);
}
/* If SUNOS shadowe system is used, use the pwdauth() function to validate
the password stored in the /etc/security/passwd.adjunct file */
int shadowed( void )
{
int pwstat;
if (pwstat = pwdauth(u.logname, u.key) == NULL)
return(0);
else
return(1);
}
/* Praise myself!!!! */
void display_notice( void )
{
system("clear");
printf("Unix Account login id & password validator.\n");
printf("For all unshadowed UNIX systems & shadowed SUNOS only.\n\n");
printf("(c)1994 The Shining\n\n\n\n");
}
/* Open a file called 'data' and store account i.d. & password along with
other information retrieved from the password file */
void write_info( void )
{
/* Open a file & store account information from pwfile in it */
if ((fp = fopen("data", "a")) == NULL) {
printf("error opening output file\n");
exit(0);
}
fprintf(fp, "%s:%s:%d:", u.logname, u.key, pwentry->pw_uid);
fprintf(fp, "%d:%s:", pwentry->pw_gid, pwentry->pw_gecos);
fprintf(fp, "%s:%s\n", pwentry->pw_dir, pwentry->pw_shell);
fclose(fp);
}
-----cut here------------------------------------------------------------------
The above programs will not compile under non-ansi C compilers without quite
a bit of modification. I have tested all these programs on SUNOS both
shadowed & unshadowed, though they should work on other systems with
little modification (except the shadow password cracker, which is SUNOS
shadow system specific).
Regards to the following guys :-
Archbishop & The Lost Avenger/UPi, RamRaider/QTX,
the guys at United International Perverts(yo Dirty Mac & Jasper!)
and all I know.
(c) 1994 The Shining (The NORTH!, U.K.)
*******************************************************************************